package com.zzyl.mapper;

import com.github.pagehelper.Page;
import com.zzyl.dto.UserDto;
import com.zzyl.entity.User;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;
import java.util.Set;

@Mapper
public interface UserMapper {

    int deleteByPrimaryKey(Long id);

    int insert(User record);

    int insertSelective(User record);

    User selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(User record);

    int updateByPrimaryKey(User record);

    /**
     * 这是Mybatis Generator拓展插件生成的方法(请勿删除).
     * This method corresponds to the database table sys_user
     *
     * @mbg.generated
     * @author hewei
     */
    int batchInsert(@Param("list") List<User> list);

    List<User> selectByRealName(String name);

    Page<List<User>> selectPage(@Param("userDto") UserDto userDto);

    /**
     * 根据部门编号批量查询部门名称
     */
    @MapKey("deptNo")
    List<Map<String, Object>> findDeptNamesByNos(@Param("deptNos") Set<String> deptNos);

    /**
     * 根据岗位编号批量查询岗位名称
     */
    @MapKey("postNo")
    List<Map<String, Object>> findPostNamesByNos(@Param("postNos") Set<String> postNos);

    int updateStatusById(@Param("id") Long id, @Param("status") String status);

    Integer deleteById(@Param("id") Long userId);

    Integer resetPwd(@Param("id") Long userId, @Param("password") String password);

    List<User> selectList(@Param("dto") UserDto userDto);

    @Select("select * from sys_user where username = #{username}")
    User selectByUsername(String username);
}